package db

import (
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"github.com/jinzhu/gorm"
	"github.com/kataras/iris/v12"
)

var db *gorm.DB
func init(){
	conn, err := gorm.Open("mysql", "root:13544425754@/movies?charset=utf8&parseTime=true")
	db = conn
	if err != nil {
		fmt.Println("Connect mysql database failed!")
		return
	}
	iris.RegisterOnInterrupt(func(){
		db.Close()
	})
}

func GetConn() *gorm.DB {
	return db
}
